These are the built-in functions of Quake C. Since they are hard-coded in C, they cannot be redefined, but they are very fast.
float anglemod (float angle)returns angle in degree, module 360.
float rint(float val)Returns val, rounded up to the closest integer value.
float floor(float val)Returns val, rounded up to the integer below (like the equivalent function in C).
float ceil(float val)Returns val, rounded up to the integer above (like the equivalent function in C).
float fabs(float val)Returns absolute value of val (like the equivalent function in C).
Returns a random floating point number between 0.0 and 1.0.
string ftos(float value)Float to string: converts value to string.
vector normalize(vector v) returns a vector of length 1Gives the vector colinear to v, but of length 1. This can be useful for calculation of distance along an axis.
float vlen(vector v)Returns the length of vector v (never < 0).
float vectoyaw(vector v) returns and angle in degreeVector to yaw: calculates the yaw angle (bearing) corresponding to a given 3D direction v.
vector vectoangles(vector v) returns vector 'pitch yaw 0 'Vector to angles: calculates the pitch angle (aiming) and yaw angle (bearing) corresponding to a given 3D direction v.
string vtos(vector v)Vector to String: print a vector, as a string.
void makevectors(vector angles) angle = 'pitch yaw 0'Calculate the vectors pointing forward, right and up, according to the provided angles.
vector v_forward; // points forward vector v_up; // points up vector v_right; // points toward the right
void sound (entity source, float channel, string sample, float volume, float attenuation) source = entity emiting the sound (ex: self) channel = channel to use for sound sample = name of the sample WAV file (ex: "ogre/ogdrag.wav") volume = 0.0 for low volume, 1.0 for maximum volume attenuation= attenuation of soundThe entity emits a sound, on one of it's 8 channels.
void ambientsound(vector position, string sample, float volume, float attenuation) position = position, in 3D space, inside the level sample = name of the sample WAV file (ex: "ogre/ogdrag.wav") volume = 0.0 for low volume, 1.0 for maximum volume attenuation= attenuation of soundAn ambient sound is emited, from the given position.
entity spawn () returns an empty entity.Create a new entity, totally empty. You can manually set every field, or just set the origin and call one of the existing entity setup functions.
void remove (entity e)Removes entity e from the world (R.I.P.).
void makestatic (entity e)Make an entity static to the world, by sending a broadcast message to the network.
entity nextent(entity e)Returns entity that is just after e in the entity list.
entity find (entity start, .string field, string match) start = begining of list to search (world, for the begining of list) field = entity field that must be examined (ex: targetname) match = value that must be matched (ex: other.target) returns the entity found, or world if no entity was found.Searches the server entity list beginning at start, looking for an entity that has entity.field = match.
Example: find the first player entity
e = find( world, classname, "player");Take care that field is a name of an entity field, without dot, and without quotes.
entity findradius (vector origin, float radius) origin = origin of sphere radius = radius of sphereReturns a chain of entities that have their origins within a spherical area.
e = findradius( origin, radius) while(e) { T_Damage(e, ... ) // Let God sort his ones! e = e.chain }
void setmodel (entity e, string model) e = entity whose model is to be set model = name of the model (ex: "progs/soldier.mdl")Changes the model associated to an entity. This model should also be declared by precache_model. Please set e.movetype and e.solid first.
void lightstyle(float style, string value) style = index of the light style, from 0 to 63. value = (ex: "abcdefghijklmlkjihgfedcb")Modifies a given light style. The light style is used to create cyclic lighting effects, like torches or teleporter lighting.
void ChangeYaw()Change the horizontal orientation of self. Turns towards self.ideal_yaw at self.yaw_speed, and sets the global variable current_yaw.
float walkmove(float yaw, float dist) returns TRUE or FALSEMoves self in the given direction.
float droptofloor() returns TRUE or FALSEDrops self to the floor, if the floor is less than -256 coordinates below.
void setorigin (entity e, vector position) e = entity to be moved position = new position for the entityMove an entity to a given location. That function is to be used when spawning an entity or when teleporting it.
void setsize (entity e, vector min, vector max) e = entity whose bounding box is to be set min = minimum, for bounding box (ex: VEC_HULL2_MIN) max = maximum, for bounding box (ex: VEC_HULL2_MAX)Set the size of the entity bounding box, relative to the entity origin. The size box is rotated by the current angle.
void movetogoal (float step)Move self toward it's goal.
vector aim(entity e, float missilespeed)Returns a vector along which the entity e can shoot.
void particle(vector origin, vector dir, float color, float count) origin = initial position dir = initial direction color = color index (73,75, count = time to live, in secondsCreate a particle effect (small dot that flies away).
color = 0 for chunk color = 75 for yellow color = 73 for blood red color = 225 for entity damage
entity checkclient()Returns client (or object that has a client enemy) that would be a valid target.
traceline (vector v1, vector v2, float nomonsters, entity forent) v1= start of line v2= end of line nomonster= if TRUE, then see through other monsters, else FALSE. forent= ignore this entity, it's owner, and it's owned entities. if forent = world, then ignore no entity.Trace a line of sight, possibly ignoring monsters, and possibly ignoring the entity forent (usually, forent = self).
float trace_allsolid; // never used float trace_startsolid; // never used float trace_fraction; // fraction (percent) of the line that was traced, before // an obstacle was hit. Equal to 1 if no obstacle were found. vector trace_endpos; // point where line ended or met an obstacle. vector trace_plane_normal; // direction vector of trace (?) float trace_plane_dist; // distance to impact along direction vector (?) entity trace_ent; // entity hit by the line float trace_inopen; // boolean, true if line went through non-water area. float trace_inwater; // boolean, true if line went through water area.
scalar checkpos (entity e, vector position)Returns true if the given entity can move to the given position from it's current position by walking or rolling.
float checkbottom(entity e) e = entity that is to be checked return TRUE or FALSEReturns TRUE if on the ground.
float pointcontents(vector pos)Returns the contents of the area situated at position pos.
void changelevel (string mapname)Warp to the game map named mapname. Actually executes the console command "changelevel" + mapname, so if you want to alias it...
void setspawnparms (entity client)Restore the original spawn parameters of a client entity.
stuffcmd (entity client, string text) client = player that is to receive the command text = text of the command, ended by \n (newline).Send a command to a given player, as if it had been typed on the player's console.
Don't forget the \n (newline) at the end, otherwise your command will not be executed, and will stand still on the console window.
Examples:
stuffcmd(self, "bf\n"); // create a flash of light on the screen stuffcmd(self, "name Buddy\n"); // name the player Buddy
Mostly used to send the command bf, that creates a flash of light on the client's screen.
void bprint (string text) text = text of the messageBroadcast a message to all players on the current server.
void centerprint( entity client, string text) client = player that is to receive the message text = text of the messageSends a message to a specific player, and print it centered.
void sprint (entity client, string text) client = player that is to receive the message text = text of the messageSends a message to a player.
void localcmd (string text) text = text of the command, ended by \n (newline).Execute a command on the server, as if it had been typed on the server's console.
Examples:
localcmd("restart\n"); // restart the level localcmd("teamplay 1\n"); // set deathmatch mode to teamplay localcmd("killserver\n"); // poor server...
void dprint (string text) text = text of the messagePrints a message to the server console.
float cvar (string variable) variable = see console variablesreturns the value of a console variable.
float cvar_set (string variable, string value) variable = see console variablessets the value of a console variable.
void eprint (entity e) e = entity to printPrint details about a given entity (for debug purposes).
void coredump()Print all entities
void traceon()Start tracing functions, end them with traceoff()
void traceoff()End traces started by traceon()
void break()Exit the programs. Never used?
void error (string text)Print an error message.
void objerror (string text)Print an error message related to object self.
Those functions are used to declare models, sounds and stuff, before the PAK file is built.
Just follow this rule: whenever one of your functions makes use of a file that's not defined in Quake, precache this file in a function that will be called by worldspawn().
Then, the QCC compiler can automatically include in the PAK file all the files that you really need to run your programs.
And when the level starts running, those precache orders will be executed, so as to attribute a fixed table index to all those files.
DO NOT USE those functions in code that will be called after worldspawn() was called. As a matter of fact, that could bomb Quake (restarting the level, without crashing the game).
Files can only be precached in spawn functions.
void precache_file(string file) file = name of the file to include in PAK file.Does nothing during game play.
void precache_model(string file) file = name of the MDL or BSP file to include in PAK file.Does nothing during game play.
void precache_sound(string file) file = name of the WAV file to include in PAK file.Does nothing during game play.